const express = require('express');
const codeExecutionController = require('../controllers/codeExecutionController');
const { protect } = require('../middlewares/authMiddleware');

const router = express.Router();

// 所有代码执行相关路由都需要登录
router.use(protect);

// 代码执行
router.post('/execute', codeExecutionController.executeCode);

// 代码验证
router.post('/validate', codeExecutionController.validateCode);

// 执行历史
router.get('/history', codeExecutionController.getExecutionHistory);

// 代码片段管理
router.post('/snippets', codeExecutionController.saveCodeSnippet);
router.get('/snippets', codeExecutionController.getCodeSnippets);

module.exports = router;